home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 January / macformat-020.iso / Shareware City / Developers / MoreFiles 1.2.1 / !MoreFiles Read Me next >
Encoding:
Text File  |  1994-08-12  |  16.1 KB  |  204 lines  |  [TEXT/ttxt]

  1. MoreFiles
  2.  
  3. A collection of File Manager and related routines
  4.  
  5. by Jim Luther, Apple Macintosh Developer Technical Support
  6. with significant code contributions by Nitin Ganatra, Apple Macintosh Developer Technical Support
  7. MoreFile Reference is by Eric Soldan
  8. Copyright © 1992-1994 Apple Computer, Inc.
  9. All rights reserved.
  10.  
  11. You may incorporate this sample code into your applications without restriction, though the sample code has been provided "AS IS" and the responsibility for its operation is 100% yours.  However, what you are not permitted to do is to redistribute the source as "DSC Sample Code" after having made changes. If you're going to re-distribute the source, we require that you make it clear in the source that the code was descended from Apple Sample Code, but that you've made changes.
  12.  
  13.  
  14. What is MoreFiles?
  15.  
  16. MoreFiles is a collection of high-level routines written over the last couple of years to answer File Manager questions developers have sent to Apple Developer Technical Support. The routines have been tested (but not stress-tested), documented, code-reviewed, and used in my own programs.
  17.  
  18.  
  19. What is MoreFiles Reference?
  20.  
  21. MoreFiles Reference is an application that lets you browse and search through much of the information in the MoreFiles C header files. MoreFiles Reference was written in a couple of evenings by Eric Soldan using AppsToGo, sample code from Developer Support.
  22.  
  23. When you launch MoreFiles Reference, it shows you the name of the header files followed by the names of all MoreFiles functions with a one line description of the functions. Typing a function’s name in the search box will select a function’s name. Clicking on a header file’s name will constrain the list of functions to that header file. Clicking on a function name will show you the API for the function and the function’s documentation.
  24.  
  25. While you’re looking at a function’s API, selecting Cut or Copy from the Edit menu will put the function’s prototype on the clipboard. The bold underlined function names in MoreFiles Reference are hot links to that function’s API and documentation.
  26.  
  27. The API button returns you to the main API list screen. The Back button takes you to the last screen viewed. The History button gives a list of recently viewed screens to move to. The Previous and Next buttons take you to the previous or next function API and description. The Page Up and Page Down do the same thing as clicking in the scroll bar.
  28.  
  29. Important Note
  30.  
  31. These routines are meant to be used from an application environment. In particular, some routines use static variables which require an A5 world and almost all routines make calls that are unsafe at interrupt time (i.e., synchronous File Manager calls and Memory Manager calls). If you plan to use these routines from stand-alone code modules, you may need to make some modifications to the code that uses static variables. Don't even think about using these routines from code that executes at interrupt time.
  32.  
  33. MoreFiles currently consists of the following files:
  34.  
  35. MoreFiles.c - the “glue code” for high-level and FSSpec style routines that were never implemented or added to the standard interface for one reason or another. If you're uncomfortable filling in parameter blocks, you'll find the code in this file very useful.
  36.  
  37. MoreFiles.h and MoreFiles.p - the documentation and header files for calling the routines included in MoreFiles.c.
  38.  
  39. Sharing.h and Sharing.p - the inline “glue code” for calling the AppleShare server routines, PBShare, PBUnshare, and PBGetUGEntry. These routines have been added to Files.h in the Universal Interfaces so they aren't used by MoreFiles. However, I've left them here in case you're still using the old interfaces.
  40.  
  41. MoreFilesExtras.c - a collection of useful File Manager utility routines for everything from searching a volume with PBCatSearch to making a file invisible.
  42.  
  43. MoreFilesExtras.h and MoreFilesExtras.p - the documentation and header files for calling the routines included in MoreFilesExtras.c. I recommend that you browse through the header files - you'll probably find a routine that you've always wanted.
  44.  
  45. FileCopy.c - a robust, general purpose file copy routine that does everything the right way. Copying a file on the Macintosh isn't as simple as you'd think if you want to handle all cases (i.e., file server drop boxes, preflighting disk space, etc.). This routine does it all and is fast, too.
  46.  
  47. FileCopy.h and FileCopy.p - the documentation and header files for calling the routines included in FileCopy.c.
  48.  
  49. DirectoryCopy.c - a general purpose recursive directory copy routine with a hook for your error handling routine.
  50.  
  51. DirectoryCopy.h and DirectoryCopy.p - the documentation and header files for calling the routines included in DirectoryCopy.c.
  52.  
  53. FSpCompat.c - the “glue code” for FSSpec style routines that will work under System 6 as much as possible. If you still need to support System 6, you'll find the code in this file very useful.
  54.  
  55. FSpCompat.h and FSpCompat.p -  the header files for calling the routines included in FSpCompat.c.  
  56.  
  57. MoreDesktopMgr.c - a collection of useful high-level Desktop Manager routines. If the Desktop Manager isn't available, the "Desktop" file is used for 'read' operations.
  58.  
  59. MoreDesktopMgr.h and MoreDesktopMgr.p - the header files for calling the routines included in MoreDesktopMgr.c.
  60.  
  61. Search.c - IndexedSearch and PBCatSearchSyncCompat. IndexedSearch performs an indexed search in and below the specified directory using the same parameters as is passed to PBCatSearch. PBCatSearchSyncCompat uses PBCatSearch (if available) or IndexedSearch (if PBCatSearch is not available) to search a volume.
  62.  
  63. Search.h and Search.p - the header files for calling the routines included in Search.c.  
  64.  
  65. MoreFiles.π - the THINK C project file you can use to build a THINK library.
  66.  
  67. MoreFiles.lib - the library built with THINK C version 6.0.1. The library is supplied two ways, with and without MacsBug debugger labels. Use the library with labels to help you debug; use the library without labels for smaller code.
  68.  
  69. MoreFilesLib.o - the library built with MPW C version 3.3.1 and MPW LIB version 3.3.1. The library is supplied two ways, with and without MacsBug debugger labels. Use the library with labels to help you debug; use the library without labels for smaller code.
  70.  
  71. FindFolderGlue.o - a library containing the FindFolder compatibility glue. This library is needed only by THINK Pascal users.
  72.  
  73. UpperString.p - a UNIT that maps UpperString to UprString for THINK Pascal users.
  74.  
  75. Worksheet - the MPW worksheet used to compile and build the MPW version of the libraries.
  76.  
  77.  
  78. How you use MoreFiles?
  79.  
  80. You can compile the code, put it in a library (or use the precompiled libraries), and link it into your programs. You can cut and paste it into your programs. You can use it as example code. Feel free to rip it off in whatever ways you find work best for you.
  81.  
  82. All routines use Pascal calling conventions so this code can be used from either C or Pascal.
  83.  
  84. You'll also notice that all routines that make other File Manager calls return an OSErr result. I always check for error results and you should too. (Well, there's a few places where I purposely ignore errors, but they're commented in the source.)
  85.  
  86.  
  87. Documentation
  88.  
  89. The documentation for the routines can be found in the header files. There, you'll find a short description of each call and a complete listing of all input and output parameters. For example, here's the documentation for one of the routines, GetFileLocation.
  90.  
  91.     /*****************************************************************************/
  92.     
  93.     pascal  OSErr   GetFileLocation(short refNum,
  94.                                     short *vRefNum,
  95.                                     long *dirID,
  96.                                     StringPtr fileName);
  97.     /*  ¶ Get the location of an open file.
  98.         The GetFileLocation function gets the location (volume reference number,
  99.         directory ID, and fileName) of an open file.
  100.         
  101.         refNum      input:  The file reference number of an open file.
  102.         vRefNum     output: The volume reference number.
  103.         dirID       output: The parent directory ID.
  104.         fileName    input:  Points to a buffer (minimum Str63) where the
  105.                             filename is to be returned or must be nil.
  106.                     output:    The filename.
  107.         
  108.         __________
  109.         
  110.         See also:   FSpGetFileLocation
  111.     */
  112.     
  113.     /*****************************************************************************/
  114.  
  115. Some routines have very few comments in their code because they simply make a single File Manager call. For those routines, the routine description is the comment. However, you'll find that more complicated routines have plenty of comments to clarify what and why the code is doing something. If something isn't clear, take a look at Inside Macintosh: Files for further reference.
  116.  
  117.  
  118. Release Notes
  119.  
  120. v1.0  09/14/93
  121.  
  122. •  First release for Developer CD
  123. ________________________________________
  124.  
  125. v1.1  01/22/94
  126.  
  127. •  MoreFiles is now built with the Universal Interfaces.
  128. •  Gave DirectoryCopy.p and MoreFilesExtras.p the correct UNIT names.
  129. •  Built MoreFiles.lib with THINK C and MoreFilesLib.o with MPW C.
  130. •  Changed the way the GetFilenameFromPathname works function (I made it work correctly for its intended purpose).
  131. •  Added GetObjectLocation function to MoreFilesExtras.
  132. •  Moved local constants from FileCopy.h to FileCopy.c.
  133. •  Moved local constants from DirectoryCopy.h to DirectoryCopy.c.
  134. •  Added Sharing.p. to go along with Sharing.h, but then didn't need either because the Universal Interfaces now include PBShare, PBUnshare, and PBGetUGEntry in Files.h.
  135. •  Added standard disclaimer to all source files.
  136. •  Fixed bug in FSpMoveRename function (it called HCopyFile instead of HMoveRename).
  137. •  Added HMoveRenameCompat and FSpMoveRenameCompat functions to MoreFilesExtras.
  138. •  Changed HOpenAware and HOpenRFAware functions in MoreFilesExtras to work around a bug in Foreign File Access (FFA) based foreign file systems (ISO 9960, High Sierra, Audio, Photo CD Access, etc.). FFA based file systems incorrectly return a wPrErr result to the OpenDeny calls instead of a paramErr result.
  139. •  Added UnmountAndEject function to MoreFilesExtras.
  140. •  The ChangeCreatorType and ChangeFDFlags functions in MoreFilesExtras no longer try (and fail) to use BumpDate on fsRtParID.
  141. •  Added DeleteDirectoryContents and DeleteDirectory functions to MoreFilesExtras.
  142. •  Removed DTS.Lib StringUtils files. The only function needed by MoreFiles was pcpy, so I dropped it into the MoreFiles sources as a static function rather than force you to include all of StringUtils.
  143. •  Fixed conditional #include in MoreFilesExtras.c.
  144. •  In MoreFilesExtras.h, changed macros for checking volume attribute bits to shift the 1L constant rather than the vMAttrib field in the GetVolParmsInfoBuffer. This produces tighter code.
  145. •  Added FSpCompat.c, FSpCompat.h, and FSpCompat.p. The FSpCompat functions let you use the System 7 FSSpec calls under System 6 (the functions use the same calling conventions as the System 7 FSSpec calls but have a modified name (for example, FSpCreate is FSpCreateCompat).
  146. •  Ran all sources through as many C compilers as possible and made minor modifications to all sources in an attempt to get rid of most warnings. There are still a couple left to fix, but I'm up against the deadline for the next Developer CD, so they'll have to wait…
  147. ________________________________________
  148.  
  149. v1.1.1  02/01/94
  150.  
  151. • Added FindFolderGlue.o and its Read Me file to the Libraries folder for THINK Pascal users.
  152. ________________________________________
  153.  
  154. v1.2  07/20/94
  155.  
  156. New Routines:
  157. •  Added GetDInfo, FSpGetDInfo, SetDInfo, FSpSetDInfo, CheckVolLock, CheckObjectLock, and FSpCheckObjectLock to MoreFilesExtras.
  158. •  Added MoreDesktopMgr. In the process, I moved GetComment, SetComment, and CopyComment over from MoreFilesExtras and changed their names (added a DT).  My apologies to anyone this API change screws up. I think the new and improved code makes up for the hassles.
  159. •  Added Search. Ever want to search a volume with PBCatSearch and it isn't available? Then you'll like this code.
  160.  
  161. Enhancements to existing routines:
  162. •  Made changes for powerc.
  163. •  THINK C project is for version 7.0.3.
  164. •  Reformatted code to meet new DTS standards for sample code.
  165. •  Added code to FileCopy to open and copy only file forks that contain data. By doing this, we won't create a data or resource fork for the copied file unless it's really needed (some foreign file systems such as the ProDOS File System and Macintosh PC Exchange have to create additional disk structures to support resource forks).
  166. •  Added code to FileCopy to copy the file attributes to the destination only if the destination is an AppleShare drop box. That way, if the file has the bundle bit set and if FileCopy is modified (by you - read the comments in the source before modification) to give up time to other processes during a copy, any Finder with access to the file won't try to read bundle information from a partially copied resource fork.
  167. •  DirectoryCopy no longer calls your CopyErrProc with a copyDirCommentOp failed operation code. There's really nothing wrong with comments not getting copied and DirectoryCopy does give it its best effort.
  168. •  Modified OpenAware and OpenRFAware functions to check for locked volume if write access is requested.
  169. •  Rewrote GetObjectLocation so that it calls PBGetCatInfo fewer times (worst case is two calls). That makes the code a little harder to read, but on slow volumes (for example, AppleShare volumes over AppleTalk Remote Access), fewer calls *is* better.
  170. •  Replaced the static pcpy functions with calls to BlockMoveData (which is BlockMove if you don't have System Update 3.0, System 7.5, or later).
  171. •  The routines in MoreDesktopMgr (used to be in MoreFilesExtras) can get APPL mappings, icons, and comments from the “Desktop” file if the Desktop Manager isn't supported by a volume.
  172. •  NameFileSearch and CreatorTypeFileSearch in MoreFilesExtras now call PBCatSearchSyncCompat in Search so that they can search on all volumes.
  173. •  Tweaked all headers so that they can be read by a future "documentation viewer" project.
  174.  
  175. Bugs fixed:
  176. •  Changed DTCopyComment to use Str255 instead of unsigned char commentBuffer[199]. PhotoCD's wrongly return up to 255 characters instead of 200 characters and that was trashing memory.
  177. •  Changed FSMakeFSSpecCompat to fix Macintosh PC Exchange 1.0.x bug.
  178. •  Fixed a couple of bugs in GetFilenameFromPathname.
  179. •  Fixed ChangeFDFlags and ChangeCreatorType to get the real vRefNum before calling BumpDate. BumpDate was “bumping” the wrong object in some cases.
  180. •  Fixed GetParentID so that it gets the right parent ID in all cases (HFS has a weird bug that I work around).
  181. •  Cleared ioFVersNum field for all PBHOpenDF, PBHOpenRF, PBHOpen, PBHCreate, PBHDelete, PBHGetFInfo, PBHSetFInfo, PBHSetFLock, PBHRstFLock, and PBHRename calls. Not needed for HFS volumes, but some of those old MFS volumes might still be around.
  182. •  Changed the macro name hasLocalList to hasLocalWList to match bit name in Files.h.
  183. ________________________________________
  184.  
  185. v1.2.1  08/09/94
  186.  
  187. New Routine:
  188. •  Added HGetVInfo to MoreFilesExtras. Like GetVInfo, this routine returns the volume name, volume reference number, and free bytes on the volume; HGetVInfo also returns the total number of bytes on the volume, and both freeBytes and totalBytes are unsigned longs so this routine returns accurate information when used on volumes larger than 2 Gigabytes.
  189.  
  190. Bugs fixed:
  191. •  Changed PBCatSearchSyncCompat to only check the bHasCatSearch bit once instead of twice in a row.
  192. •  Changed CheckForMatches to pass EqualString cPB->hFileInfo.ioNamePtr instead of the uninitialized variable itemName. Now, searching using fsSBFullName works.
  193. •  Changed PreflightFileCopySpace to use unsigned variables in space calculations.
  194. •  Changed PreflightDirectoryCopySpace to use unsigned variables in space calculations. Now, I'm 4 GB clean.
  195. ________________________________________
  196.  
  197. Thanks (you know who you are) for the bug reports and suggestions that helped me improve MoreFiles since the last version(s). If you find any more bugs or have any comments, please let me know at:
  198.  
  199. AppleLink: DEVFEEDBACK
  200.  
  201. Internet: devfeedback@AppleLink.Apple.com
  202.  
  203. Please put "Attn: Jim Luther" in the message title.
  204.